// DlgInsertFrame.cpp : implementation file
//

#include "stdafx.h"
#include "ansieditor.h"
#include "DlgInsertFrame.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgInsertFrame dialog


CDlgInsertFrame::CDlgInsertFrame(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgInsertFrame::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgInsertFrame)
	m_nPageCount = 1;
	m_nInsertDirection = 1;
	m_bCopyContent = TRUE;
	//}}AFX_DATA_INIT
}


void CDlgInsertFrame::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgInsertFrame)
	DDX_Control(pDX, IDC_SPIN_PAGECOUNT, m_spinPageCount);
	DDX_Text(pDX, IDC_EDIT_PAGECOUNT, m_nPageCount);
	DDV_MinMaxInt(pDX, m_nPageCount, 1, 512);
	DDX_Radio(pDX, IDC_RADIO1, m_nInsertDirection);
	DDX_Check(pDX, IDC_CHECK_COPY_CONTENT, m_bCopyContent);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgInsertFrame, CDialog)
	//{{AFX_MSG_MAP(CDlgInsertFrame)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgInsertFrame message handlers

BOOL CDlgInsertFrame::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	if(GetAppContext()->m_pAnimateList->IsWindowVisible())
	{
		CRect rect, rcList, rcView;
		GetWindowRect(rect);
		int w = rect.Width();
		int h = rect.Height();
		GetAppContext()->m_pAnimateList->GetWindowRect(rcList);
		GetAppContext()->m_pView->GetWindowRect(rcView);
		if(rcList.left < rcView.left)
		{
			rect.left = rcView.left + 10;
			rect.right = rect.left + w;
			rect.top = (rcView.top + rcView.bottom - h - 30) / 2 - 60;
			rect.bottom = rect.top + h;
			MoveWindow(rect);
		}
	}
	m_spinPageCount.SetRange(1, 512);

	m_nInsertDirection = gpApp->GetProfileInt("Dialog", "InsertFrame.InsertDirection", m_nInsertDirection);
	m_nPageCount = gpApp->GetProfileInt("Dialog", "InsertFrame.PageCount", m_nPageCount);
	m_bCopyContent = gpApp->GetProfileInt("Dialog", "InsertFrame.CopyContent", m_bCopyContent);
	UpdateData(FALSE);

	gpApp->m_mui.UpdateDialog(this, IDD);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgInsertFrame::OnOK() 
{
	UpdateData(TRUE);
	gpApp->WriteProfileInt("Dialog", "InsertFrame.InsertDirection", m_nInsertDirection);
	gpApp->WriteProfileInt("Dialog", "InsertFrame.PageCount", m_nPageCount);
	gpApp->WriteProfileInt("Dialog", "InsertFrame.CopyContent", m_bCopyContent);
	CDialog::OnOK();
}
